1 00:00:00,370 --> 00:00:05,410 Before we start scripting the code that will progress our story, we need to set up the functionality 2 00:00:05,410 --> 00:00:06,520 for a few more things. 3 00:00:06,520 --> 00:00:11,770 One of those things is going to be our camera manipulation handler here on the client, and this is 4 00:00:11,770 --> 00:00:16,600 going to be responsible for listening to events, for manipulating the position of the camera, changing 5 00:00:16,600 --> 00:00:20,110 the occlusion mode of the camera, displaying jumpscares, and so on. 6 00:00:20,110 --> 00:00:24,850 We have actually a total of four module scripts we need to set up for camera manipulation. 7 00:00:24,850 --> 00:00:30,730 That being this handler, this jumpscares module script, the night vision module script. 8 00:00:30,730 --> 00:00:34,840 And then we need to set up a new enum inside of replicated storage. 9 00:00:34,840 --> 00:00:36,790 So we can go to the enums folder. 10 00:00:36,790 --> 00:00:39,850 And what I'll do is I'll just duplicate one of these enums here. 11 00:00:40,720 --> 00:00:45,760 And we're going to rename this to Camera Manipulation enum. 12 00:00:46,270 --> 00:00:48,340 And we can go ahead and open that up as well. 13 00:00:48,700 --> 00:00:52,900 So to get started we're going to go back into our camera manipulation handler. 14 00:00:53,140 --> 00:00:58,150 And inside of our camera manipulation handler we're going to need a total of four services. 15 00:00:58,150 --> 00:01:00,370 We're going to need to get replicated storage. 16 00:01:03,190 --> 00:01:05,770 We're going to need the player service. 17 00:01:07,230 --> 00:01:09,720 We will need the tween service. 18 00:01:11,600 --> 00:01:14,510 And then we're going to need the sound service. 19 00:01:17,130 --> 00:01:20,370 Now we can create the table that will represent this module script. 20 00:01:20,370 --> 00:01:22,710 So we can just call it camera manipulation. 21 00:01:23,810 --> 00:01:27,290 And we'll make sure to return that at the end of our module script. 22 00:01:27,590 --> 00:01:29,990 And then we need a few more variables. 23 00:01:29,990 --> 00:01:33,440 One we need a reference to our modules folder on the client. 24 00:01:33,440 --> 00:01:36,890 So that's going to be equal to the script dot parent dot parent. 25 00:01:36,890 --> 00:01:38,540 And then we get the modules folder. 26 00:01:38,780 --> 00:01:41,630 We're going to make a reference to the player's current camera. 27 00:01:41,630 --> 00:01:44,120 So that's in the workspace dot current camera. 28 00:01:44,120 --> 00:01:48,710 We're going to get the local player player's dot local player. 29 00:01:48,710 --> 00:01:51,950 We will need to refer to two different events. 30 00:01:51,950 --> 00:01:58,730 One is a bindable event to allow local scripts to communicate with this handle, or to do different 31 00:01:58,730 --> 00:02:00,410 camera manipulation stuff. 32 00:02:00,410 --> 00:02:07,310 So we can call this manipulate cam Bindable and that's in replicated storage dot events, dot Bindable 33 00:02:07,310 --> 00:02:08,540 dot manipulate camera. 34 00:02:08,540 --> 00:02:14,780 And then we also need to refer to an event that the server can use to tell specific players to do different 35 00:02:14,780 --> 00:02:15,620 camera stuff. 36 00:02:15,620 --> 00:02:18,380 So we can call this manipulate cam event. 37 00:02:18,380 --> 00:02:23,150 And that's in replicated storage dot events, dot remotes, dot manipulate camera. 38 00:02:23,150 --> 00:02:28,370 Last but not least, we can go ahead and require our camera manipulation enum. 39 00:02:28,370 --> 00:02:35,030 So require and replicated storage dot modules dot enums dot camera manipulation enum. 40 00:02:35,030 --> 00:02:41,150 Now inside of this enum we can go ahead and delete these actions in here, because we're going to have 41 00:02:41,150 --> 00:02:43,100 to replace these with different actions. 42 00:02:43,100 --> 00:02:49,940 So in the client section we want to have the ability to, for example, move our camera to a specific 43 00:02:49,940 --> 00:02:51,290 position or C frame. 44 00:02:51,290 --> 00:02:54,950 So we can have this action be called move camera two. 45 00:02:55,480 --> 00:03:01,720 We want to have the ability to reset the camera or basically make the camera go back to the player, 46 00:03:01,720 --> 00:03:06,490 put it back in first person mode, and allow the player to have full control over the camera again. 47 00:03:06,490 --> 00:03:08,800 So we can call this reset camera. 48 00:03:11,610 --> 00:03:15,390 We want to have the ability to rotate our camera. 49 00:03:18,230 --> 00:03:21,170 We want to have the ability to jump scare our player. 50 00:03:21,170 --> 00:03:26,390 So when the server wants to jump scare a specific player, they'll fire that remote event and give us 51 00:03:26,390 --> 00:03:28,130 the action of like a jump scare. 52 00:03:30,080 --> 00:03:34,280 We want to have the ability to change the camera's occlusion mode. 53 00:03:34,310 --> 00:03:40,820 Now, the default occlusion mode is the one that we all know where the player's camera collides with 54 00:03:40,820 --> 00:03:41,720 objects, right? 55 00:03:41,720 --> 00:03:45,830 We're not allowed to pass the player's camera through different objects, but there's other occlusion 56 00:03:45,830 --> 00:03:51,290 modes where the camera is allowed to pass through different objects, and those objects can have their 57 00:03:51,290 --> 00:03:54,320 transparency changed to see directly through them. 58 00:03:54,320 --> 00:04:00,110 So when we're spectating other players, we want to be able to change the camera's occlusion mode to 59 00:04:00,110 --> 00:04:01,940 see through different parts of the map. 60 00:04:02,000 --> 00:04:06,800 So we can call this action set camera occlusion mode. 61 00:04:11,900 --> 00:04:17,210 And then one more action we'll need is to be able to toggle night vision as well, because when we're 62 00:04:17,210 --> 00:04:22,880 spectating, it's going to be pitch black and we're not going to be able to see anything unless we enable 63 00:04:22,880 --> 00:04:24,380 for us to have night vision. 64 00:04:24,380 --> 00:04:26,030 So we can see across the map. 65 00:04:26,030 --> 00:04:28,730 So we can call this toggle night vision. 66 00:04:31,560 --> 00:04:34,020 And then inside of the two server section. 67 00:04:34,020 --> 00:04:40,740 The only action that we need to give to the server is to change the camera's occlusion, because unfortunately, 68 00:04:40,740 --> 00:04:44,040 we can't change the camera's occlusion mode from the client side. 69 00:04:44,040 --> 00:04:47,970 We actually have to tell the server to change it for the player. 70 00:04:48,000 --> 00:04:54,090 So we'll have an action to give to the server and we'll call it change camera occlusion. 71 00:04:56,460 --> 00:04:59,400 And this is going to be a server only action. 72 00:04:59,730 --> 00:05:04,350 Now back inside of our camera manipulation handler we'll need a couple more variables. 73 00:05:04,350 --> 00:05:07,620 One is we're going to require our jump scare module. 74 00:05:07,620 --> 00:05:10,560 So that's going to be inside of our modules folder. 75 00:05:10,800 --> 00:05:13,020 Camera manipulation dot jump scares. 76 00:05:13,020 --> 00:05:16,710 And then we're also going to require our night vision module script. 77 00:05:16,710 --> 00:05:21,060 So require modules dot camera manipulation dot night vision. 78 00:05:21,540 --> 00:05:23,670 And we can go ahead and hop on those real quick. 79 00:05:23,670 --> 00:05:26,880 We don't need to fill out jump scares for now, because we're going to be doing that later. 80 00:05:26,880 --> 00:05:29,820 But we can quickly make the table to represent this module script. 81 00:05:29,820 --> 00:05:34,740 So we'll just call it jump scares, and then we'll make sure to return that at the end here. 82 00:05:34,740 --> 00:05:37,620 And then we could do the same thing for the night vision. 83 00:05:37,860 --> 00:05:43,590 We'll make a variable called night vision and return that at the end of our script. 84 00:05:44,170 --> 00:05:47,590 And then one last variable we'll need is a random data type. 85 00:05:47,620 --> 00:05:50,890 Now some different private functions we're going to need is one. 86 00:05:50,890 --> 00:05:55,090 We need a function to tween our camera to a specific position. 87 00:05:55,090 --> 00:06:00,520 So this will get passed some tween data and a goal for the camera. 88 00:06:00,520 --> 00:06:04,990 And we can use the tween service and create it on our current camera. 89 00:06:05,080 --> 00:06:07,030 Do tween info. 90 00:06:08,290 --> 00:06:09,610 Dot new. 91 00:06:10,090 --> 00:06:17,020 And because, uh, we cannot pass tween information through remote events, then we're going to have 92 00:06:17,020 --> 00:06:22,870 to, you know, ensure that we unpack all the stuff inside of this tween data table. 93 00:06:22,870 --> 00:06:27,130 So we're going to use table dot unpack tween data. 94 00:06:27,770 --> 00:06:29,180 And then we can pass our goal. 95 00:06:29,180 --> 00:06:31,190 And then we could just play this tween. 96 00:06:31,520 --> 00:06:34,700 We need a function to reset our camera. 97 00:06:35,640 --> 00:06:41,790 And then we need a function to listen to our different, uh, binomial event and remote event. 98 00:06:41,790 --> 00:06:46,680 So we can call this on cam manipulation event. 99 00:06:46,680 --> 00:06:50,400 We'll get past an action and arguments to go with that action. 100 00:06:50,760 --> 00:06:54,960 And then all we need for this handler is to have an initialize function. 101 00:06:54,960 --> 00:06:57,300 So camera manipulation in it. 102 00:06:57,300 --> 00:07:02,310 And the only purpose of this is to listen to when our cam Bindable event gets fired. 103 00:07:02,310 --> 00:07:05,520 And we'll connect our on cam init event function. 104 00:07:05,520 --> 00:07:12,300 And then we're going to do the same thing for the cam event dot on client event and connect on camera 105 00:07:12,300 --> 00:07:13,830 manipulate event. 106 00:07:14,250 --> 00:07:18,930 So inside of our on camera manipulation event function we need to listen to several different actions. 107 00:07:18,930 --> 00:07:25,980 For example, if the action is equal to our camera manipulation enum dot two client dot move camera 108 00:07:25,980 --> 00:07:32,130 to somewhere, then what we could do is we could set the current camera camera type equal to enum dot 109 00:07:32,130 --> 00:07:33,630 camera TypeScript label. 110 00:07:33,660 --> 00:07:37,620 Because we're only going to be able to tween and move the camera around when it's in its scriptable 111 00:07:37,620 --> 00:07:38,280 state. 112 00:07:38,280 --> 00:07:45,390 And then we can use our tween camera two function and pass the args dot tween data. 113 00:07:45,390 --> 00:07:49,410 So uh, this table will contain a key for the tween data. 114 00:07:49,410 --> 00:07:53,190 And then we can also have a key for the goal of the camera. 115 00:07:53,190 --> 00:07:55,080 So we can just call it camera goal. 116 00:07:55,260 --> 00:07:58,050 And our function will go ahead and take care of that for us. 117 00:07:58,740 --> 00:08:04,500 Otherwise, if our action is equal to the camera manipulation enum dot two client dot. 118 00:08:04,500 --> 00:08:09,270 Uh, let's say reset camera, then we can call our reset camera function and do that, and we'll fill 119 00:08:09,270 --> 00:08:10,470 that out in a moment. 120 00:08:11,100 --> 00:08:15,810 If the action is equal to camera manipulation enum dot two client dot. 121 00:08:15,810 --> 00:08:17,550 Let's say rotate camera. 122 00:08:18,290 --> 00:08:24,950 Then what we would do is we would also set the current camera camera type equal to the enum dot camera 123 00:08:24,950 --> 00:08:26,330 type dot scriptable. 124 00:08:27,000 --> 00:08:32,970 And then what we would do is we would use C frame angles to get a C frame with just a rotation. 125 00:08:32,970 --> 00:08:35,460 So we can do C frame dot angles. 126 00:08:35,460 --> 00:08:40,650 And we'll have another key pass to this function. 127 00:08:40,650 --> 00:08:44,100 And we could call it something like args dot rotation. 128 00:08:44,100 --> 00:08:47,250 So we could have a table containing the x, y and z rotation. 129 00:08:47,250 --> 00:08:52,110 And we can unpack those values into our c frame dot angles. 130 00:08:53,970 --> 00:08:59,460 And then now something very important to note is we want this action to define for us whether or not 131 00:08:59,460 --> 00:09:05,130 we're just rotating the camera around some specific point, or we want the player's camera to rotate 132 00:09:05,130 --> 00:09:07,620 around itself when it's in first person mode. 133 00:09:07,620 --> 00:09:15,330 And this is very important because inside of a first person mode, uh, the player's camera is not directly 134 00:09:15,330 --> 00:09:17,490 set into the center of the player's head. 135 00:09:17,490 --> 00:09:21,330 It's actually offset behind the player's head just a little bit. 136 00:09:21,330 --> 00:09:27,420 So we need to make sure that we account for that offset when we create the key frame that we want to 137 00:09:27,420 --> 00:09:32,430 set the camera to, so we can create a variable called goal key frame. 138 00:09:32,640 --> 00:09:39,120 And with this function inside of the arguments table, we can have a boolean like rotate around head. 139 00:09:39,120 --> 00:09:40,950 And we could set that to true or false. 140 00:09:40,950 --> 00:09:45,840 If it's true, then what we could do is we could set goal key frame equal to a new key frame. 141 00:09:45,840 --> 00:09:52,920 And the position is going to be equal to the local player character dot head dot position. 142 00:09:52,920 --> 00:09:55,710 So this is if our players in first person. 143 00:09:55,710 --> 00:10:03,150 And then what we want to do is we want to subtract this position or offset it by the rotation dot look 144 00:10:03,150 --> 00:10:03,900 vector. 145 00:10:04,170 --> 00:10:10,350 So for example, if we wanted to rotate the camera around the player's head, the actual position of 146 00:10:10,350 --> 00:10:14,760 the camera is like about one stud behind the head's position. 147 00:10:14,760 --> 00:10:21,180 So we're getting the look vector and we're subtracting it by the head's position to get that offset 148 00:10:21,180 --> 00:10:24,360 of about one stud behind the player's head. 149 00:10:24,360 --> 00:10:32,040 That way, when we set the player's, uh, camera type back to be custom, it's not going to snap back 150 00:10:32,040 --> 00:10:37,590 to the, uh, original camera position of our player when they're in first person. 151 00:10:37,590 --> 00:10:42,450 That might not make sense, but trust me, it's important that we subtract our position by the look 152 00:10:42,450 --> 00:10:45,030 vector of the rotation that we were past. 153 00:10:45,030 --> 00:10:50,160 And then once we do that, we actually need to also apply the rotation on the key frame, because right 154 00:10:50,160 --> 00:10:53,310 now we just have a key frame with a position but no rotation. 155 00:10:53,310 --> 00:10:57,240 So we need to make sure we add our key frame dot angles as well. 156 00:10:57,240 --> 00:11:01,320 So we'll add or basically multiply it by the rotation. 157 00:11:01,320 --> 00:11:02,760 We're not actually multiplying. 158 00:11:02,760 --> 00:11:07,800 This is just a symbol we're using to add this rotation to our key frame. 159 00:11:08,340 --> 00:11:13,890 Now, if we don't need to rotate the camera around the player's head, then this will be a lot easier. 160 00:11:14,040 --> 00:11:22,320 All we can do is just set goal keyframe equal to see frame dot new current camera dot keyframe dot position 161 00:11:22,320 --> 00:11:25,650 and multiply it or add this rotation. 162 00:11:25,830 --> 00:11:33,330 Then we can use our tween camera two function, and we can pass the tween data that gets passed to our, 163 00:11:33,330 --> 00:11:34,650 uh, action. 164 00:11:34,920 --> 00:11:42,930 And then we'll have a goal table which will be changing the see frame of our camera equal to this goal 165 00:11:42,960 --> 00:11:43,770 keyframe. 166 00:11:44,670 --> 00:11:48,570 Now the next action we can listen to in our camera manipulation enum. 167 00:11:49,360 --> 00:11:52,810 Is, let's say we need to jump scare the player. 168 00:11:52,810 --> 00:11:58,120 Well, this is when we would use our jump scare module and use a function in there to jump scare the 169 00:11:58,120 --> 00:12:00,430 player, but we're not going to fill that out just yet. 170 00:12:00,430 --> 00:12:02,470 So we're just going to leave this empty for now. 171 00:12:03,170 --> 00:12:11,300 Another action we can listen to is let's say we need to, um, set the camera's occlusion mode to something 172 00:12:11,300 --> 00:12:11,990 else. 173 00:12:12,660 --> 00:12:18,780 So what we would do is we would get the enum that we need to set the occlusion mode to. 174 00:12:18,810 --> 00:12:26,100 So we can have this args table contain a key that contains the occlusion mode for the camera. 175 00:12:26,100 --> 00:12:31,620 And then we would take this occlusion mode and use our manipulation cam event and fire to the server 176 00:12:31,620 --> 00:12:38,280 using the action of camera manipulation enum dot two server dot change camera occlusion. 177 00:12:38,280 --> 00:12:42,690 And we could tell them that hey, we want to change it to this particular enum. 178 00:12:42,690 --> 00:12:48,030 So we could do occlusion mode is equal to this enum. 179 00:12:48,890 --> 00:12:56,030 Last but not least, the action we need to listen to right here is when we need to set the night vision 180 00:12:56,030 --> 00:12:56,840 for our camera. 181 00:12:56,840 --> 00:12:59,660 So that toggle night vision. 182 00:12:59,660 --> 00:13:04,730 We would also use our night vision module script, and we could have a function in there like toggle. 183 00:13:04,730 --> 00:13:10,250 And we could pass it a true or false boolean to either turn on or off the night vision. 184 00:13:10,250 --> 00:13:16,220 So we could have another key inside of our args table, such as like we could call it set on. 185 00:13:16,220 --> 00:13:20,360 And this will be the Boolean to tell us whether or not we need to turn on or off the night vision. 186 00:13:20,780 --> 00:13:25,430 Now, before we fill out this function, let's go ahead and fill out our reset camera function first. 187 00:13:25,430 --> 00:13:33,830 So inside of here, what we need to do is we want to move the player's camera back to the first person 188 00:13:33,830 --> 00:13:34,610 position. 189 00:13:34,610 --> 00:13:39,410 And instead of snapping the camera back to the first person position, I actually want to tween it there. 190 00:13:39,410 --> 00:13:44,120 So we can create a tween using the tween service create on our current camera. 191 00:13:44,630 --> 00:13:48,470 We could do a tween info of like 0.5 seconds. 192 00:13:49,200 --> 00:13:56,010 And then we want to change the C frame of our camera, and we want to set it equal to a C frame.nu of 193 00:13:56,010 --> 00:14:01,080 the local player, dot character, dot head dot position. 194 00:14:01,080 --> 00:14:06,900 And again, because the first person position of the camera is slightly offset from the center of the 195 00:14:06,900 --> 00:14:13,350 head, we need to subtract this by the current camera dot c frame dot look vector. 196 00:14:13,350 --> 00:14:19,770 So this will put our camera as close as possible to the first person position. 197 00:14:20,460 --> 00:14:27,360 And then we can also multiply this by the current cam dot c frame dot rotation. 198 00:14:27,930 --> 00:14:32,790 So we'll move the player's camera back to their head so we can play this tween. 199 00:14:33,090 --> 00:14:35,700 And then we'll wait for this tween to complete. 200 00:14:36,390 --> 00:14:43,710 And then after it completes, we can set the local player dot camera max zoom distance equal to 0.5 201 00:14:43,710 --> 00:14:49,440 and set the local player dot camera minimum zoom distance equal to 0.5 so they can't zoom out. 202 00:14:49,560 --> 00:14:57,210 We can set the local player dot camera mode equal to the enum dot camera mode, dot lock, first person. 203 00:14:57,450 --> 00:15:03,030 And just in case the occlusion mode of our camera is not the default occlusion mode, what we could 204 00:15:03,030 --> 00:15:07,320 do is we could use our manipulate cam event and fire to the server. 205 00:15:07,320 --> 00:15:14,250 So camera manipulation enum dot two server dot change camera occlusion. 206 00:15:14,840 --> 00:15:21,620 We could pass a table with the occlusion mode, and that mode is going to be the default, which is 207 00:15:21,620 --> 00:15:26,270 the enum.dev camera occlusion mode dot zoom. 208 00:15:26,750 --> 00:15:34,040 After that, we can set the current cam dot camera type back to the enum dot camera type dot custom. 209 00:15:34,040 --> 00:15:35,870 So it goes back to the first person mode. 210 00:15:35,870 --> 00:15:38,570 And the default camera scripts have control again. 211 00:15:38,660 --> 00:15:45,350 And then we can set the current cam dot camera subject equal to the local player. 212 00:15:46,500 --> 00:15:47,460 Dot character. 213 00:15:47,460 --> 00:15:48,840 Dot humanoid. 214 00:15:49,490 --> 00:15:49,970 Okay. 215 00:15:49,970 --> 00:15:50,420 Perfect. 216 00:15:50,450 --> 00:15:54,230 Now we can go ahead and fill out the toggle function for our night vision. 217 00:15:54,230 --> 00:16:00,860 So in order to achieve a night vision effect, we first need to tint the color of the player's screen 218 00:16:00,860 --> 00:16:01,910 to be green. 219 00:16:01,910 --> 00:16:07,100 And then we also want to change the ambient lighting in our game so the player can see farther away. 220 00:16:07,370 --> 00:16:13,430 And the way we would do that is we would get the player's camera and we would add a color correction 221 00:16:13,430 --> 00:16:14,330 effect. 222 00:16:14,330 --> 00:16:18,740 And inside of here we could set the brightness to be like 0.2. 223 00:16:18,740 --> 00:16:21,080 So we can increase the brightness on the screen. 224 00:16:21,080 --> 00:16:24,530 We would want to increase the contrast as well. 225 00:16:24,530 --> 00:16:27,920 We would want to set the saturation to something like negative one. 226 00:16:27,920 --> 00:16:34,460 And then we would want to tint the color to a green color like we could do something. 227 00:16:35,440 --> 00:16:42,730 Like this, and then afterwards we would also have to set the ambient inside of the lighting service 228 00:16:42,730 --> 00:16:44,020 to a brighter color. 229 00:16:44,020 --> 00:16:50,860 So if we do something like this, we're able to see farther across the map than if the ambient was at 230 00:16:50,860 --> 00:16:51,700 the black state. 231 00:16:51,700 --> 00:16:54,490 So as you can see, our night vision doesn't really work. 232 00:16:54,490 --> 00:16:58,660 But if we increase the ambient now, it looks like our night vision is working. 233 00:16:59,240 --> 00:17:04,220 So that means inside of our toggle function, we're going to have to add this color correction effect 234 00:17:04,220 --> 00:17:07,400 and change the ambient in our lighting service. 235 00:17:08,020 --> 00:17:11,920 So inside of here we can create a function for our night vision. 236 00:17:11,920 --> 00:17:13,480 And it's going to be called toggle. 237 00:17:13,480 --> 00:17:17,650 And we're going to get passed a boolean of whether or not we want to set this on or off. 238 00:17:18,790 --> 00:17:22,090 We need to refer to our lighting service. 239 00:17:24,950 --> 00:17:29,720 And then we're going to need a variable to refer to our current camera in the workspace. 240 00:17:29,720 --> 00:17:31,550 So workspace dot current camera. 241 00:17:32,000 --> 00:17:36,260 We want to have a boolean to keep track of whether or not our night vision is on. 242 00:17:36,260 --> 00:17:39,860 So is night vision on. 243 00:17:39,860 --> 00:17:42,170 We'll set that to false as default. 244 00:17:42,170 --> 00:17:44,150 And then we need some constants. 245 00:17:44,240 --> 00:17:49,610 One of these constants is going to be the lighting ambient original. 246 00:17:49,610 --> 00:17:51,290 So what's the original ambient. 247 00:17:51,290 --> 00:17:53,840 Well it's going to be equal to the lighting dot ambient. 248 00:17:54,320 --> 00:17:59,300 And then we can have a lighting ambient bright. 249 00:18:00,450 --> 00:18:03,150 And that's going to be color three from RGB. 250 00:18:03,150 --> 00:18:07,290 And we could just basically bang this up all the way to the max. 251 00:18:07,290 --> 00:18:10,290 So we get 255, 255, 255. 252 00:18:10,470 --> 00:18:13,170 And then we also want to have a green color in here. 253 00:18:13,170 --> 00:18:15,870 So that's going to be equal to color three from RGB. 254 00:18:16,990 --> 00:18:20,440 We can go in here and get a green color. 255 00:18:20,440 --> 00:18:21,370 So. 256 00:18:25,070 --> 00:18:26,570 Make it slightly darker. 257 00:18:26,570 --> 00:18:28,820 Something like that would probably work. 258 00:18:29,180 --> 00:18:34,940 And then inside of our toggle function, we need to check if we want to set the night vision on or off. 259 00:18:34,940 --> 00:18:41,720 So if set on and we want to make sure that our night vision isn't already on and not is night vision 260 00:18:41,750 --> 00:18:46,670 on, what we could do is we could set is night vision on equal to true. 261 00:18:46,670 --> 00:18:49,070 We're going to get a new color correction effect. 262 00:18:49,070 --> 00:18:54,320 So color is equal to instance dot new color correction effect. 263 00:18:54,830 --> 00:19:00,470 We're going to set the name of this color correction effect equal to night vision effect. 264 00:19:01,220 --> 00:19:06,140 We can set the color dot brightness equal to like 0.2. 265 00:19:07,280 --> 00:19:11,150 We'll set the color dot contrast equal to point two. 266 00:19:11,570 --> 00:19:15,200 The color saturation is going to be equal to negative one. 267 00:19:15,680 --> 00:19:19,070 The color tint color is going to be equal to our green color. 268 00:19:19,460 --> 00:19:21,230 And then the parent. 269 00:19:21,830 --> 00:19:25,010 Of this color correction effect is going to be inside of our current camera. 270 00:19:25,010 --> 00:19:31,430 And then inside of the lighting service we can set the ambient equal to our lighting ambient bright. 271 00:19:31,430 --> 00:19:34,310 So this will create that night vision effect for us. 272 00:19:34,310 --> 00:19:40,520 And then if we want to disable our night vision so else if not set on. 273 00:19:41,370 --> 00:19:45,060 Then what we could do is set is night vision on equal to false. 274 00:19:45,090 --> 00:19:48,600 We'll check to see if the player has this color correction effect. 275 00:19:48,600 --> 00:19:51,720 So current cam find first child. 276 00:19:51,720 --> 00:19:54,750 And we're going to get the night vision effect. 277 00:19:55,220 --> 00:19:59,630 So if they have this color correction effect, then we need to destroy it. 278 00:20:01,220 --> 00:20:07,400 And then we need to set the lighting ambient Mac to the lighting ambient original. 279 00:20:07,670 --> 00:20:10,880 Okay, I think that's all we need to do here. 280 00:20:11,150 --> 00:20:14,990 Uh, we need to continue setting up, uh, some things before we can start our story. 281 00:20:14,990 --> 00:20:17,210 So I'll go ahead and see you in the next lecture.